package org.yjc.service;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.yjc.entity.Eim;
import org.yjc.repository.EimRepository;

@Service
public class EimService {
	@Autowired
	private EimRepository eimDAO;

	public Page<Eim> findByLesseeId(Pageable pageable, Integer lesseeId) {
		return eimDAO.findByLesseeId(pageable,lesseeId);
	}

	public Page<Eim> findByLesseeId(Specification spec, Pageable pageable, Integer lesseeId) {
		return eimDAO.findByLesseeId(spec,pageable,lesseeId);
	}

	public void deleteById(int parseInt) {
		eimDAO.deleteById(parseInt);
	}

	public Page<Eim> findAll(Specification spec, Pageable pageable) {
		return eimDAO.findAll(spec, pageable);
	}

	public Eim findById(int parseInt) {
		Optional<Eim> optional = eimDAO.findById(parseInt);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}

	public void save(Eim eim) {
		eimDAO.save(eim);
	}
}
